package com.gitee.wsl.collections.list

import androidx.collection.IntList
import androidx.collection.MutableIntList


/**
 * @return a read-only [IntList] with nothing in it.
 */
fun Lists.emptyIntList(): IntList = androidx.collection.emptyIntList()

/**
 * @return a read-only [IntList] with nothing in it.
 */
fun Lists.intListOf(): IntList = androidx.collection.intListOf()

/**
 * @return a new read-only [IntList] with [element1] as the only item in the list.
 */
fun Lists.intListOf(element1: Int): IntList = mutableIntListOf(element1)

/**
 * @return a new read-only [IntList] with 2 elements, [element1] and [element2], in order.
 */
fun Lists.intListOf(element1: Int, element2: Int): IntList =
    mutableIntListOf(element1, element2)

/**
 * @return a new read-only [IntList] with 3 elements, [element1], [element2], and [element3],
 * in order.
 */
fun Lists.intListOf(element1: Int, element2: Int, element3: Int): IntList =
    mutableIntListOf(element1, element2, element3)

/**
 * @return a new read-only [IntList] with [elements] in order.
 */
fun Lists.intListOf(vararg elements: Int): IntList =
    MutableIntList(elements.size).apply { plusAssign(elements) }

/**
 * @return a new empty [MutableIntList] with the default capacity.
 */
fun Lists.mutableIntListOf(): MutableIntList = MutableIntList()

/**
 * @return a new [MutableIntList] with [element1] as the only item in the list.
 */
fun Lists.mutableIntListOf(element1: Int): MutableIntList {
    val list = MutableIntList(1)
    list += element1
    return list
}

/**
 * @return a new [MutableIntList] with 2 elements, [element1] and [element2], in order.
 */
fun Lists.mutableIntListOf(element1: Int, element2: Int): MutableIntList {
    val list = MutableIntList(2)
    list += element1
    list += element2
    return list
}

/**
 * @return a new [MutableIntList] with 3 elements, [element1], [element2], and [element3],
 * in order.
 */
fun Lists.mutableIntListOf(element1: Int, element2: Int, element3: Int): MutableIntList {
    val list = MutableIntList(3)
    list += element1
    list += element2
    list += element3
    return list
}

/**
 * @return a new [MutableIntList] with the given elements, in order.
 */
fun Lists.mutableIntListOf(vararg elements: Int): MutableIntList =
    MutableIntList(elements.size).apply { plusAssign(elements) }